package com.zzxy.po;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;


public abstract class User implements BeanNameAware, BeanFactoryAware, DisposableBean{
    private String username;
    private String password;
    private int age;
    private Address address;

    /**
     * @return
     */
    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", age=" + age +
                ", address=" + address +
                '}';
    }

    public User(String username,String password){
        this.username = username;
        this.password = password;
    }


    /**
     * @return
     */
    @Override
    public String toString(){
        return "User{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", age=" + age +
                '}';
    }

    public String getUsername(){return username;}

    public void setUsername(String username,Integer age){
        System.out.println("2. populate properties 封装属性");
        this.username = username;
    }

    public String getPassword(){return password;}

    public void setPassword(String password){this.password = password;}

    public User(){System.out.println("1.instantiate bean对象实体化");}

    @Override
    public void setBeanName(String s) {System.out.println("3.如果Bean实现BeanNameAware执行setBeanName");}

    public void setBeanFactory(BeanFactoryAware beanFactory) throws BeansException {
        System.out.println("4.如果Bean实现BeanFactoryAware执行setBeanFactory,获取Spring容器");
    }


    public void afterPropertiesSet() throws Exception {
        System.out.println("6.如果Bean实现IintializingBean执行afterPropertiesSet");
    }

    public void myInit(){System.out.println("7.调用<bean init-method=\"init\">指定初始化方法 init");}

    @Override
    public void destroy() throws Exception {
        System.out.println("9.如果Bean实现 DispsableBean执行destory");
    }

    public void myDestory(){System.out.println("10.调用<bean destory-method=\"customerDestory\">指定销毁方法 customerDestory");}

    public java.lang.Object getName() {
    }
}
